import React from 'react';
import { useParams } from 'react-router-dom';
import TodayMarket from './realtime/TodayMarket.tsx';
import SelectedStocks from './realtime/SelectedStocks.tsx';
import AssetMonitoring from './realtime/AssetMonitoring.tsx';
import RiskWarning from './realtime/RiskWarning.tsx';
import AutoTradingPage from './realtime/AutoTradingPage.js';
import ManualTradingPage from './realtime/ManualTradingPage.js';
import StrategySelection from './realtime/StrategySelection.tsx';
import ManualSelection from './realtime/ManualSelection.tsx';

const RealTimeMarket = () => {
  const { subpage } = useParams();
  console.log("subpage=", subpage);
  
  // 如果没有二级页面参数，使用默认值
  const currentSubpage = subpage || 'today'; // 确保默认值为 'today'
  console.log("currentSubpage=", currentSubpage);
  const getPageTitle = () => {
    switch(currentSubpage) {
      case 'real-time-board': return '实时盘面';
      case 'stocks': return '自选个股';
      case 'auto-trading': return '自动交易';
      case 'manual-trading': return '人工交易';
      case 'asset-monitor': return '资产监测';
      case 'risk-alert': return '风险预警';
      case 'strategy-selection': return '策略自选';
      case 'manual-selection': return '手动自选';
      default: return '实时交易';
    }
  };
  
  const getPageContent = () => {
    switch(currentSubpage) {
      case 'real-time-board':
        return <TodayMarket />;
      case 'stocks':
        return <SelectedStocks />;
      case 'asset-monitor':
        return <AssetMonitoring />;
      case 'risk-alert':
        return <RiskWarning />;
      case 'auto-trading':
        return <AutoTradingPage />;
      case 'manual-trading':
        return <ManualTradingPage />;
      case 'strategy-selection':
        return <StrategySelection />;
      case 'manual-selection':
        return <ManualSelection />;
      default:
        return <p>请从左侧选择分析类型</p>;
    }
  };

  return (
    <div className="page-container">
      <h2>实时交易 - {getPageTitle()}</h2>
      {getPageContent()}
    </div>
  );
};

export default RealTimeMarket;